package utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.persistence.Entity;

import controllers.Interventions;

public class ControlData_old{

	String errorFind;
	
	public boolean verifyDates(String beginDateString, String endDateString){
		boolean correctDataEntry = true;
		if(!compareDate(beginDateString, endDateString)){
			errorFind = "La date de début doit être avant la date de fin";
			correctDataEntry = false;
		}
		return correctDataEntry;
	}
	
	public static Date parseToDate(String dateString){
        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
        Date dateParse = new Date();	
        try {
        	dateParse = sdf.parse(dateString);
		} catch (ParseException e) {
			e.printStackTrace();
		}
        return dateParse;
	}
	
	private boolean compareDate(String beginDateString, String endDateString){
//        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
        Date beginDate = parseToDate(beginDateString);
        Date endDate = parseToDate(endDateString);
//        try {
//			beginDate = sdf.parse(beginDateString);
//			endDate = sdf.parse(endDateString);
//		} catch (ParseException e) {
//			e.printStackTrace();
//		}
        
        return beginDate.before(endDate);
	}	
}
